//var FileManager = FileManager || {};

FileManager.RemoteMethods = function() {	
	this.remote = new Ext.app.RemoteCall({
		url : "../file/service" ,
		service : "fileManager" ,
		type : "org.jwos.plugin.file.service.FileManager"	
	});	
};

FileManager.RemoteMethods.prototype = {

	login: function(sessionId, OnSuccess, scope, timeout) {
        this.remote.invoke('login', sessionId, OnSuccess, scope, timeout);
    },

    HelloWorld: function(msg, OnSuccess, scope, timeout) {
        this.remote.invoke('helloWorld', {'msg':msg, 'sessionId':MyDesktop.currentSessionId}, OnSuccess, scope, timeout);
    },
    
    CreateFolder: function(parentId, name, OnSuccess, scope) {
        this.remote.invoke('createFolder', {'parentId':parentId, 'name':name, 'sessionId':MyDesktop.currentSessionId}, OnSuccess, scope);
    },
    
    RenameFolder: function(folderId, name, OnSuccess, scope) {
        this.remote.invoke('renameFolder', {'folderId':folderId, 'name':name, 'sessionId':MyDesktop.currentSessionId}, OnSuccess, scope);
    }, 
    
    RenameFile: function(fileId, name, OnSuccess, scope) {
        this.remote.invoke('renameFile', {'fileId':fileId, 'name':name, 'sessionId':MyDesktop.currentSessionId}, OnSuccess, scope);
    },      
    
    CommentFile: function(fileId, comment, OnSuccess, scope) {
        this.remote.invoke('CommentFile', {'fileId':fileId, 'comment':comment, 'sessionId':MyDesktop.currentSessionId}, OnSuccess, scope);
    },    
    
    Delete: function(folderIds, fileIds, OnSuccess, scope) {
        this.remote.invoke('delete', {'folderIds':folderIds, 'fileIds':fileIds, 'sessionId':MyDesktop.currentSessionId}, OnSuccess, scope, 600000);
    },        
    
    Move: function(folderIds, fileIds, targetFolderId, OnSuccess, scope) {
        this.remote.invoke('move', {'folderIds':folderIds, 'fileIds':fileIds, 'targetFolderId':targetFolderId, 'sessionId':MyDesktop.currentSessionId}, OnSuccess, scope, 600000);
    },          
    
    Copy: function(folderIds, fileIds, targetFolderId, OnSuccess, scope) {
        this.remote.invoke('copy', {'folderIds':folderIds, 'fileIds':fileIds, 'targetFolderId':targetFolderId, 'sessionId':MyDesktop.currentSessionId}, OnSuccess, scope, 600000);
    },
    
    EmptyRecycleBin: function(OnSuccess, scope) {
        this.remote.invoke('EmptyRecycleBin', {'sessionId':MyDesktop.currentSessionId}, OnSuccess, scope);
    },      
    
    Compress: function(folderIds, fileIds, archiveName, compressionLevel, password, targetFolderId, OnSuccess, scope) {
        this.remote.invoke('Compress', {'folderIds':folderIds, 'fileIds':fileIds, 'archiveName':archiveName, 'compressionLevel':compressionLevel, 'password':password, 'targetFolderId':targetFolderId, 'sessionId':MyDesktop.currentSessionId}, OnSuccess, scope, 600000);
    },  
    
    Extract: function(fileId, password, targetFolderId, OnSuccess, scope) {
        this.remote.invoke('Extract', {'fileId':fileId, 'password':password, 'targetFolderId':targetFolderId, 'sessionId':MyDesktop.currentSessionId}, OnSuccess, scope, 600000);
    },    
    
    GetUploadObject: function(folderId, OnSuccess, scope) {
        this.remote.invoke('getUploadObject', {'folderId':folderId, 'sessionId':MyDesktop.currentSessionId}, OnSuccess, scope);
    },    
    
    GetUploadStatus: function(postBackId, OnSuccess, scope) {
        this.remote.invoke('getUploadStatus', {'postBackId':postBackId, 'sessionId':MyDesktop.currentSessionId}, OnSuccess, scope);
    },         
    
    GetAllTags: function(OnSuccess, scope) {
        this.remote.invoke('GetAllTags', {'sessionId':MyDesktop.currentSessionId}, OnSuccess, scope);
    }, 
    
    GetTags: function(folderIds, fileIds, OnSuccess, scope) {
        this.remote.invoke('GetTags', {'folderIds':folderIds, 'fileIds':fileIds, 'sessionId':MyDesktop.currentSessionId}, OnSuccess, scope);
    },
    
    AddTags: function(folderIds, fileIds, tags, OnSuccess, scope) {
        this.remote.invoke('AddTags', {'folderIds':folderIds, 'fileIds':fileIds, 'tags':tags, 'sessionId':MyDesktop.currentSessionId}, OnSuccess, scope);
    },              
    
    RemoveTag: function(tag, OnSuccess, scope) {
        this.remote.invoke('RemoveTag', {'tag':tag, 'sessionId':MyDesktop.currentSessionId}, OnSuccess, scope);
    },
    
    EmailFiles: function(fileIds, to, subject, body, OnSuccess, scope) {
        this.remote.invoke('emailFiles', {'fileIds':fileIds, 'to':to, 'subject':subject, 'body':body, 'sessionId':MyDesktop.currentSessionId}, OnSuccess, scope);
    }, 
    
    GetSharedItem: function(folderId, OnSuccess, scope) {
        this.remote.invoke('getSharedItem', {'folderId':folderId, 'sessionId':MyDesktop.currentSessionId}, OnSuccess, scope);
    },  
    
    SaveSharedItem: function(folderId, enabled, comment, permissions, OnSuccess, scope) {
        this.remote.invoke('saveSharedItem', {'folderId':folderId, 'enabled':enabled, 'comment':comment, 'permissions':permissions, 'sessionId':MyDesktop.currentSessionId}, OnSuccess, scope);
    }, 
    
    SendSharingNotificationEmails: function(folderId, users, OnSuccess, scope) {
        this.remote.invoke('SendSharingNotificationEmails', {'folderId':folderId, 'users':users, 'sessionId':MyDesktop.currentSessionId}, OnSuccess, scope);
    },     
    
    PublishFile: function(fileId, enableExpiration, expireDate, update, OnSuccess, scope) {
        this.remote.invoke('publishFile', {'fileId':fileId, 'enableExpiration':enableExpiration, 'expireDate':expireDate, 'update':update, 'sessionId':MyDesktop.currentSessionId}, OnSuccess, scope);
    },      
    
    UnPublishFile: function(fileId, OnSuccess, scope) {
        this.remote.invoke('unPublishFile', {'fileId':fileId, 'sessionId':MyDesktop.currentSessionId}, OnSuccess, scope);
    },
    
    PublishFolder: function(folderId, enableExpiration, expireDate, enablePassword, password, enableComment, comment, update, OnSuccess, scope) {
        this.remote.invoke('publishFolder', {'folderId':folderId, 'enableExpiration':enableExpiration, 'expireDate':expireDate, 'enablePassword':enablePassword, 'password':password, 'enableComment':enableComment, 'comment':comment, 'update':update, 'sessionId':MyDesktop.currentSessionId}, OnSuccess, scope);
    },      
    
    UnPublishFolder: function(folderId, OnSuccess, scope) {
        this.remote.invoke('unPublishFolder', {'folderId':folderId, 'sessionId':MyDesktop.currentSessionId}, OnSuccess, scope);
    },        
    
    EmailPublishLink: function(resourceType, link, rss, emails, OnSuccess, scope) {
        this.remote.invoke('EmailPublishLink', {'resourceType':resourceType, 'link':link, 'rss':rss, 'emails':emails, 'sessionId':MyDesktop.currentSessionId}, OnSuccess, scope);
    },  
    
    TreeNodeCollapse: function(folderId, OnSuccess, scope) {
        this.remote.invoke('treeNodeCollapse', {'folderId':folderId, 'sessionId':MyDesktop.currentSessionId}, OnSuccess, scope);
    },   
    
    GetCompletePathList: function(OnSuccess, scope) {
        this.remote.invoke('getCompletePathList', {'sessionId':MyDesktop.currentSessionId}, OnSuccess, scope);
    },
    
    GetFolderIdByPath: function(path, save, OnSuccess, scope) {
        this.remote.invoke('getFolderIdByPath', {'path':path,'save':save,'sessionId':MyDesktop.currentSessionId}, OnSuccess, scope);
    },   
    
    GetAddressBook: function(OnSuccess, scope) {
        this.remote.invoke('getAddressBook', {'sessionId':MyDesktop.currentSessionId}, OnSuccess, scope);
    },         
    
    AddAddress: function(email, name, OnSuccess, scope) {
        this.remote.invoke('AddAddress', {'email':email,'name':name, 'sessionId':MyDesktop.currentSessionId}, OnSuccess, scope);
    },   
    
    RemoveAddress: function(email, OnSuccess, scope) {
        this.remote.invoke('RemoveAddress', {'email':email, 'sessionId':MyDesktop.currentSessionId}, OnSuccess, scope);
    },     
    
    GetSubUsers: function(OnSuccess, scope) {
        this.remote.invoke('getSubUsers', {'sessionId':MyDesktop.currentSessionId}, OnSuccess, scope);
    },   
    
    GetFileManagerSettings: function(OnSuccess, scope) {
        this.remote.invoke('GetFileManagerSettings', {'sessionId':MyDesktop.currentSessionId}, OnSuccess, scope);
    },    
    
    SaveFileManagerSetting: function(key, value, OnSuccess, scope) {
        this.remote.invoke('saveFileManagerSetting', {'key':key,'value':value, 'sessionId':MyDesktop.currentSessionId}, OnSuccess, scope);
    },
    
    SendEmail: function(emails, subject, body, OnSuccess, scope) {
        this.remote.invoke('SendEmail', {'emails':emails,'subject':subject,'body':body, 'sessionId':MyDesktop.currentSessionId}, OnSuccess, scope);
    },  
    
    UploadFromUrl: function(url, folderId, fileName, OnSuccess, scope) {
        this.remote.invoke('UploadFromUrl', {'url':url,'folderId':folderId,'fileName':fileName, 'sessionId':MyDesktop.currentSessionId}, OnSuccess, scope, 3600000);
    }    
}